<template>
  <div class="cell_group">
    <div class="cell">
      <div class="title">
        {{config.attrName}}
      </div>
      <div class="picker" @click="goSelectCar">
        <div class="select-car" :class="{'placeholder':!pickerValue}">
          {{pickerValue?pickerValue:'请选择'+config.attrName}}
        </div>
        <img src="@/assets/img/right.png" alt="">
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "select-car",
  props: {
    config: {
      type: Object,
      required: true
    },
    parentIndex: Number,
    itemIndex: Number
  },
  data() {
    return {
      popupShow: false,
      pickerValue: ""
    };
  },
  watch: {
    config(n) {
      //
      if (n.value) {
        this.pickerValue = n.value;
        this.$store.commit("onChoosecarInfo", n.value);
      }
    }
  },
  created() {
    if (this.$store.state.choosecarInfo) {
      this.pickerValue = this.$store.state.choosecarInfo;
      this.config.value = this.pickerValue;
      this.$emit("changeValue", this.parentIndex, this.itemIndex, this.config);
    } else if (this.config.value) {
      this.pickerValue = this.config.value;
    } else {
      this.config.value = "";
    }
  },
  methods: {
    goSelectCar() {
      this.$router.replace({ name: "select_car", params: { data: 1 } });
    }
  }
};
</script>
<style lang="less">
.picker {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.4rem;
  font-family: PingFangSC-Regular;
  color: #666666;
  width: 60%;
  height: 100%;

  img {
    width: 0.186667rem;
    height: 0.346667rem;
    padding-left: 0.213333rem;
  }
  .select-car {
    width: calc(100% - 0.186667rem);
    height: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: right;
    line-height: 1.333333rem;
  }
  .placeholder {
    color: #dadada;
    font-size: 0.426667rem;
  }
}
</style>

